Page({
  data: {
    result: {}
  },
  onLoad () {
    this.getCloud()
  },
  getCloud () {
    wx.showNavigationBarLoading()
    wx.$API['activityPage/getCloudResource']({}).then((result) => {
      wx.hideNavigationBarLoading()
      const { data } = result
      if (data.length) {
        this.setData({
          result: data[0]
        })
      }
    }).catch((err) => {
      console.log(err)
      wx.hideNavigationBarLoading()
    })
  },
  copy (e) {
    const { name } = e.currentTarget.dataset
    wx.setClipboardData({
      data: this.data.result[name] || '',
      fail: (err) => {
        wx.showToast({
          title: '复制失败',
          icon: 'none',
          duration: 2000
        })
        console.log(err)
      }
    })
  }
})